<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			.wrap{
				width: 200px;
				height: 200px;
				border: 1px solid black;
				position: relative;
			}
			.scale{
				width:20px;
				height:20px;
				background: red;
				position: absolute;
				right:0px;
				bottom: 0px;
				cursor:nw-resize;
			}
		</style>
		<script type="text/javascript">
			window.onload=function(){
				var oWrap=document.querySelector('.wrap');
				var oScale=document.querySelector('.scale');
				//alert(oWrap);//[object htmldivelement]
				var shortx=0;
				var shorty=0;
				oScale.onmousedown=function(ev){
					var ev=ev||window.event;
					//shortx=ev.offsetX;
					//shorty=ev.offsetY;
					shortx=ev.clientX-oScale.offsetLeft;
					shorty=ev.clientY-oScale.offsetTop;
					document.onmousemove=function(ev){
						var ev=ev||window.event;
						oScale.style.left=ev.clientX-shortx+'px';
						oScale.style.top=ev.clientY-shorty+'px';
						oWrap.style.width=ev.clientX-shortx+20+'px';
						oWrap.style.height=ev.clientY-shorty+20+'px';
						
					}
					document.onmouseup=function(){
						document.onmousemove=null;
						document.onmouseup=null;
					}
					return false;
				}
			}
		</script>
	</head>
	<body>
		<textarea name="" rows="" cols=""></textarea>
		<div class="wrap">
			<div class="scale"></div>
		</div>
	</body>
</html>
